// Decompiled by DJ v3.11.11.95 Copyright 2009 Atanas Neshkov  Date: 2/1/2010 3:33:10 AM
// Home Page: http://members.fortunecity.com/neshkov/dj.html  http://www.neshkov.com/dj.html - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   OthelloNewGameDialog.java

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class OthelloNewGameDialog extends JDialog
    implements ActionListener, ItemListener
{

    public OthelloNewGameDialog(Frame frame, boolean flag, boolean flag1, boolean flag2)
    {
        super(frame, "Start New Game", true);
        setDefaultCloseOperation(2);
        okPressed = false;
        blackIsHuman = flag;
        whiteIsHuman = flag1;
        animateTiles = flag2;
        buildUI();
        setSize(300, 200);
    }

    public boolean okPressed()
    {
        return okPressed;
    }

    public boolean blackIsHuman()
    {
        return blackIsHuman;
    }

    public boolean whiteIsHuman()
    {
        return whiteIsHuman;
    }

    public boolean animateTiles()
    {
        return animateTiles;
    }

    private void buildUI()
    {
        Container container = getContentPane();
        GridBagLayout gridbaglayout = new GridBagLayout();
        container.setLayout(gridbaglayout);
        JLabel jlabel = new JLabel("Black: ");
        container.add(jlabel);
        gridbaglayout.setConstraints(jlabel, new GridBagConstraints(0, 0, 1, 1, 0.0D, 0.0D, 13, 0, new Insets(5, 5, 5, 5), 0, 0));
        blackHumanButton = new JRadioButton("Human", blackIsHuman);
        blackHumanButton.addActionListener(this);
        container.add(blackHumanButton);
        gridbaglayout.setConstraints(blackHumanButton, new GridBagConstraints(1, 0, 1, 1, 0.0D, 0.0D, 10, 0, new Insets(5, 5, 5, 5), 0, 0));
        blackCPUButton = new JRadioButton("CPU", !blackIsHuman);
        blackCPUButton.addActionListener(this);
        container.add(blackCPUButton);
        gridbaglayout.setConstraints(blackCPUButton, new GridBagConstraints(2, 0, 1, 1, 0.0D, 0.0D, 10, 0, new Insets(5, 5, 5, 5), 0, 0));
        JLabel jlabel1 = new JLabel("White: ");
        container.add(jlabel1);
        gridbaglayout.setConstraints(jlabel1, new GridBagConstraints(0, 1, 1, 1, 0.0D, 0.0D, 13, 0, new Insets(5, 5, 5, 5), 0, 0));
        whiteHumanButton = new JRadioButton("Human", whiteIsHuman);
        whiteHumanButton.addActionListener(this);
        container.add(whiteHumanButton);
        gridbaglayout.setConstraints(whiteHumanButton, new GridBagConstraints(1, 1, 1, 1, 0.0D, 0.0D, 10, 0, new Insets(5, 5, 5, 5), 0, 0));
        whiteCPUButton = new JRadioButton("CPU", !whiteIsHuman);
        whiteCPUButton.addActionListener(this);
        container.add(whiteCPUButton);
        gridbaglayout.setConstraints(whiteCPUButton, new GridBagConstraints(2, 1, 1, 1, 0.0D, 0.0D, 10, 0, new Insets(5, 5, 5, 5), 0, 0));
        animateCheckbox = new JCheckBox("Animate tile-flipping", animateTiles);
        animateCheckbox.addItemListener(this);
        container.add(animateCheckbox);
        gridbaglayout.setConstraints(animateCheckbox, new GridBagConstraints(0, 2, 3, 1, 0.0D, 0.0D, 10, 0, new Insets(5, 5, 5, 5), 0, 0));
        okButton = new JButton("OK");
        okButton.addActionListener(this);
        container.add(okButton);
        gridbaglayout.setConstraints(okButton, new GridBagConstraints(1, 3, 1, 1, 0.0D, 0.0D, 10, 0, new Insets(5, 5, 5, 5), 0, 0));
        cancelButton = new JButton("Cancel");
        cancelButton.addActionListener(this);
        container.add(cancelButton);
        gridbaglayout.setConstraints(cancelButton, new GridBagConstraints(2, 3, 1, 1, 0.0D, 0.0D, 10, 0, new Insets(5, 5, 5, 5), 0, 0));
    }

    public void actionPerformed(ActionEvent actionevent)
    {
        Object obj = actionevent.getSource();
        if(obj == okButton)
        {
            okPressed = true;
            processWindowEvent(new WindowEvent(this, 201));
        } else
        if(obj == cancelButton)
        {
            okPressed = false;
            processWindowEvent(new WindowEvent(this, 201));
        } else
        if(obj == blackHumanButton)
        {
            blackCPUButton.setSelected(false);
            blackIsHuman = true;
        } else
        if(obj == blackCPUButton)
        {
            blackHumanButton.setSelected(false);
            blackIsHuman = false;
        } else
        if(obj == whiteHumanButton)
        {
            whiteCPUButton.setSelected(false);
            whiteIsHuman = true;
        } else
        if(obj == whiteCPUButton)
        {
            whiteHumanButton.setSelected(false);
            whiteIsHuman = false;
        }
    }

    public void itemStateChanged(ItemEvent itemevent)
    {
        Object obj = itemevent.getSource();
        if(obj == animateCheckbox)
            animateTiles = itemevent.getStateChange() == 1;
    }

    private JRadioButton blackHumanButton;
    private JRadioButton blackCPUButton;
    private JRadioButton whiteHumanButton;
    private JRadioButton whiteCPUButton;
    private JCheckBox animateCheckbox;
    private JButton okButton;
    private JButton cancelButton;
    private boolean okPressed;
    private boolean blackIsHuman;
    private boolean whiteIsHuman;
    private boolean animateTiles;
}
